using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public interface CatTrigger
{
	
}

public interface CatInvoker
{
	CatTrigger getCatTrigger ();
	
	void run ();
}

public abstract class AbstractCatInvoker<T> : CatInvoker where T : CatTrigger
{
	public T catTrigger;
	
	public AbstractCatInvoker (T catTrigger)
	{
		this.catTrigger = catTrigger;
	}
	
	public CatTrigger getCatTrigger ()
	{
		return catTrigger;
	}
	
	abstract public void run ();
}

public class UICat : MonoBehaviour
{
	protected List<CatInvoker> catInvokerList = new List<CatInvoker> () ;
	
	public void addCatInvoker (CatInvoker catInvoker)
	{
		catInvokerList.Add (catInvoker);
	}
	
	public void removeCatTrigger (CatTrigger catTrigger)
	{
		int count = catInvokerList.Count;
		for (int i = 0; i < count; i++) {
			if (catInvokerList [i].getCatTrigger () == catTrigger) {
				catInvokerList.RemoveAt (i);
				break;
			}
		}
	}
	
	void OnClick ()
	{
		foreach (CatInvoker catInvoker in catInvokerList) {
			catInvoker.run ();
		}
	}
}
